import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tianpu_edu/Classes/My/VC/my_settring_page.dart';
import 'package:tianpu_edu/Classes/libs/tool_image_utils.dart';
import 'package:tianpu_edu/Classes/libs/tool_navigation_utils.dart';
import 'package:tianpu_edu/Classes/libs/tool_text_utils.dart';

class MyView extends StatefulWidget {
  @override
  _MyViewState createState() => _MyViewState();
}

class _MyViewState extends State<MyView> {

  // List _myData = ['系统消息','选课咨询','意见反馈','设置'];
  List<MyData> _myData = [
    MyData('系统消息', '编组 3'),
    MyData('选课咨询', '编组 19'),
    MyData('意见反馈', '编组 4'),
    MyData('设置', '矩形(1)'),
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: CustomScrollView(
        physics: NeverScrollableScrollPhysics(),
        slivers: <Widget>[
          _headerWidget(),
          SliverList(
            delegate: SliverChildBuilderDelegate(
                  (BuildContext context, int index) {
                return InkWell(
                  child: Container(
                    // color: Colors.red,
                    height: 70,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            SizedBox(width: 20,),
                            // Icon(Icons.accessibility_new),
                            loadAssetImageAll(_myData[index].image,all: 35),
                            SizedBox(width: 18,),
                            Text('${_myData[index].name}',style: textStyle(),),
                          ],
                        ),
                        Row(
                          children: <Widget>[
                            // Icon(Icons.accessibility_new),
                             loadAssetImage('路径',height: 25),
                            SizedBox(width: 20,),
                          ],
                        ),

                      ],

                    ),

                  ),
                  onTap: (){
                    if(_myData[index].name == '设置'){
                      NavigationUtil.pushPage(context, MySettingPage());
                    }
                  },
                );
              },
              childCount: _myData.length,

            ),
          )
        ],
      ),
    );
  }

  Widget _headerWidget(){
    return SliverToBoxAdapter(
      child: Container( height: 320,
        decoration: BoxDecoration(
            image: new DecorationImage(
              fit: BoxFit.cover,
              image: loadAssetsImageType('编组 10'),
            )),
        child: Stack(
          children: [
            Positioned(
              left: 10,
              right: 10,
              bottom: 10,
              child: Container(
                height: 220,
                decoration: BoxDecoration(
                    image: new DecorationImage(
                      fit: BoxFit.cover,
                      image: loadAssetsImageType('编组'),
                    )),
                child: Container(
                  padding: EdgeInsets.all(20),
                  child: Column(
                    children: [
                      Row(children: [
                        loadAssetImageAll('编组 3(1)',all: 80),
                        SizedBox(width: 6,),
                        Column(crossAxisAlignment: CrossAxisAlignment.start,
                          children: [Text('登录/注册',style: textStyle(),),
                            SizedBox(height: 6,),
                          Text('登录/注册后开启更多功能',style: textStyle(color: Colors.grey)),],),

                      ],),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceAround,
                        children: [
                          _headerCell('矩形(2)','我的订单'),
                          _headerCell('矩形的副本','历史课程'),
                          _headerCell('编组 5','我的学习卡'),
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _headerCell(String image, String name) => Container(
    child: Column(
      children: [
        SizedBox(height: 12,),
        loadAssetImageAll(image,all: 35),
        SizedBox(height: 12,),
        Text(name,style: textStyle(),)
      ],
    ),
  );
}

class MyData {

  final String name;
  final String image;

  MyData(this.name, this.image);

}
